package com.tom;

import com.tom.rpc.v2.RpcServer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * 启动
 *
 * @author yanghongjun19
 * @date 2021/01/06
 */
@SpringBootApplication
public class ProductServiceApplication {


    @Value("${zookeeper.con}")
    public String zookeeperCon;


    public static void main(String[] args) {
        SpringApplication.run(ProductServiceApplication.class, args);
    }

    @Bean
    public RpcRegister rpcRegister() {
        return new RpcRegister(zookeeperCon);
    }

    @Bean
    public RpcServer rpcServer(ApplicationContext applicationContext, RpcRegister rpcRegister) {
        return new RpcServer("127.0.0.1", 9000, applicationContext, rpcRegister);
    }
}
